package com.qianclass.talklive.app.im;

import com.qianclass.talklive.app.activity.VideoActivity;

import static android.R.attr.type;

public class IMInstance implements IMEgineEvent {
	private VideoActivity activity;
	public IMInstance(VideoActivity activity){
		this.activity=activity;
	}
	public void OnRegister(int errCode, int userId, String userAccount)
	{		
		System.out.println( "OnRegister:" +userId+","+ userAccount + "," + errCode);
		activity.OnRegister(userId,errCode,userAccount);
	}
	public int OnUnRegister(int errCode)
	{ 
		System.out.println( "OnUnRegister:" + errCode);
		if(errCode != ConstantDefination.RESULT_SUCCESS)
			return errCode;
		return 0; 
	}
	public void OnJoinGroup(int errCode, String groupCode, String userList)
	{
		System.out.println( "OnJoinGroup:" + groupCode + "," + userList + "," + errCode);
		activity.OnJoinGroup(errCode,groupCode,userList);
	}

	@Override
	public void OnGroupUserList(int errCode, String groupCode, String userList){
		System.out.println( "OnGroupUserList:" + groupCode + "," + userList);
	}

	public void OnLeaveGroup(int errCode, String groupCode)
	{
		System.out.println( "OnLeaveGroup:" + groupCode + "," + errCode);
	}
	public void OnUserJoinGroup(int errCode, String userAccount, String userName, int userType)
	{
		System.out.println( "OnUserJoinGroup:" + userAccount + "," + userName + userType);
		activity.OnUserJoinGroup(userAccount,userName,userType);
	}
	public void OnUserLeaveGroup(int errCode,
								 String userAccount,
								 String userName,
								 int userType,
								 int leaveType)
	{
		System.out.println( "OnUserLeaveGroup:" + userAccount + "," + userName + userType);
		activity.OnUserLeaveGroup(userAccount,userName,userType,leaveType);
	}
	public void OnReceiveMessage(String messageData)
	{
		System.out.println( "OnReceiveMessage:" + messageData);
	}
	public void OnReceiveGroupMessage(String messageData)
	{
		System.out.println( "OnReceiveGroupMessage:" + messageData);
		activity.OnReceiveGroupMessage(messageData);
	}

	@Override
	public void onLockUserAccount(int errCode, int userId, int lockType) {
		System.out.println( "onLockUserAccount:" + errCode + "," + userId + "," + type);
	}

	public void OnLostConnection(int errcode)
	{
		System.out.println( "OnLostConnection:" + errcode + "");
	}
	public void OnConnectionError(int errcode)
	{
		System.out.println( "OnConnectionError:" + errcode + "");
		activity.OnConnectionError();
	}
	public void OnError(int errCode)
	{
		System.out.println( "xxOnError:" + errCode + "");
		activity.OnError(errCode);
	}

	public void OnServerNotification(int errCode)
	{
		System.out.println("OnServerNotification"+errCode);
		activity.OnServerNotification(errCode);
	}
}